<?php

namespace app\common\model;

use think\Request;
use think\Exception;

/**
 * 
 * Class User
 * @package app\common\model
 */
class MemberMoneyLog extends BaseModel
{
   protected $name = 'member_money';
   protected $autoWriteTimestamp = false;

   public static function incrMoneyLog($post, $memberObj)
   {
   		$post['member_id'] = $memberObj['uid'];	
   		$post['before'] = $memberObj['money'] - $post['change'];
   		$post['after'] = $memberObj['money'];
   		return self::createMoenyLog($post);
   	}

   	public static function decrMoneyLog($post,$memberObj)
   	{
   		$post['member_id'] = $memberObj['uid'];	
   		$post['before'] = $memberObj['money'] + $post['change'];
   		$post['after'] = $memberObj['money'];
   		return self::createMoenyLog($post);
   	}
   
   	public static function createMoenyLog($post)
   	{
   		$post['add_time'] = date('Y-m-d H:i:s');
   		return self::create($post);
   	}
}
